/**
 * @author [siwi]
 * @email [siwi@siwi.me]
 * @create date 2017-08-27 01:19:42
 * @modify date 2017-08-27 01:19:42
 * @desc [单例模式连接redis]
*/
'use strict';
const Redis = require('ioredis')

let __instance = (function () {
  let instance
  return (newInstance) => {
    if (newInstance) instance = newInstance
    return instance
  }
}())

class Siwi {
  constructor() {
    if (__instance()) return __instance()
    this.connect = new Redis(6379, '127.0.0.1')
    __instance(this)
  }
}

module.exports = new Siwi()